#include <stdio.h>

int main(int argc, const char *argv[])
{
	char a;
	short b;
	int c;
	long d;
	long long e;
	float f;
	double g;
	// 64位系统sizeof计算的结果是long类型
	// long ret = sizeof(a);  // 正确的写法
	// printf("ret = %ld\n", ret);
	
	// 有时候也会看到下面的写法
	int ret = sizeof(a); // 由于sizeof计算的是变量占用的内存大小
				// 一般不会超过int的存储范围 所以此处的强转一般也认为是安全的
	printf("ret = %d\n", ret);
	
	// 也可以直接将结果打印到终端
	printf("sizeof(char) = %ld  sizeof(a) = %ld\n", sizeof(char), sizeof(a)); // 1
	printf("sizeof(short) = %ld  sizeof(b) = %ld\n", sizeof(short), sizeof(b)); // 2
	printf("sizeof(int) = %ld  sizeof(c) = %ld\n", sizeof(int), sizeof(c)); // 4
	printf("sizeof(long) = %ld  sizeof(d) = %ld\n", sizeof(long), sizeof(d)); // 4 或者 8
	printf("sizeof(long long) = %ld  sizeof(e) = %ld\n", sizeof(long long), sizeof(e)); // 8
	printf("sizeof(float) = %ld  sizeof(f) = %ld\n", sizeof(float), sizeof(f)); // 4
	printf("sizeof(double) = %ld  sizeof(g) = %ld\n", sizeof(double), sizeof(g)); // 8

	return 0;
}
